package com.core.framework.web.easyweb.context;

import java.io.Serializable;
import java.util.Map;

import com.core.framework.web.easyweb.EasywebStatics;
/**
 * EasyWeb上下文集装器
 * @author 刘涛
 * @since Jun 25, 2012
 */
public class ActionContext implements  EasywebStatics , Serializable
{
	private static final long serialVersionUID = 1L;
    static ThreadLocal<Object> actionContext = new ThreadLocal<Object>();
    Map<String,Object> context; 
    
    public ActionContext( Map<String,Object> contextMap) 
    {
    	context =contextMap;
    }
    public static void setContext(ActionContext context) {
        actionContext.set(context);
    }
    public static ActionContext getContext() {
        return (ActionContext) actionContext.get();
    }
    public void setContextMap(Map<String, Object> contextMap) {
        getContext().context = contextMap;
    }
    public Map<String, Object> getContextMap() {
        return context;
    }
    public void setApplication(Object application) {
        put(APPLICATION, application);
    }

    public Object getApplication() {
        return (Object) get(APPLICATION);
    }
    public Object get(String key) {
        return context.get(key);
    }
    public void put(String key, Object value) {
        context.put(key, value);
    }
}
